package com.yingxin.yx.framework.redis.queue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("redisQueueSupport")
public class RedisQueueSupport {


    @Autowired
    @Qualifier("jacksonRedisTemplate")
    private RedisTemplate redisTemplate;

    public long size(String k) {
        return redisTemplate.opsForList().size(k);
    }

    public <T> void push(String k, T t) {
        redisTemplate.opsForList().leftPush(k, t);
    }

    public <T> void pushAll(String k, List<T> list) {
        redisTemplate.opsForList().leftPushAll(k, list);
    }

    public Object pop(String k) {
        return redisTemplate.opsForList().rightPop(k);
    }


}
